package one.stand.controller;

import com.jmp.autocofiguration.web.interceptor.SecurityAuthCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.model.ResultModel;
import one.stand.request.CompanyCustomerLableRequest;
import one.stand.response.CompanyCustomerLableResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/companyCustomerLable")
@Api(description = "企业与客户标签")
public class CompanyCustomerLableController extends BaseController {

    @ApiOperation(value = "添加标签")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lableColor", value = "标签颜色", paramType = "Long"),
            @ApiImplicitParam(name = "lableName", value = "标签名", paramType = "Long"),
            @ApiImplicitParam(name = "parentId", value = "父级id 为0表示自己就是父级", paramType = "Long"),
    })
    @PostMapping("addLable")
    @SecurityAuthCheck(company = true, card = true, isBoss = true)
    public ResultModel<Long> addLable(@RequestAttribute CompanyCustomerLableRequest request) {

        return crmFegin.addLable(request);
    }

    @ApiOperation(value = "删除标签")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lableId", value = "标签id", paramType = "Long"),
    })
    @PostMapping("delLable")
    @SecurityAuthCheck(company = true, card = true, isBoss = true)
    public ResultModel<Boolean> delLable(@RequestAttribute CompanyCustomerLableRequest request) {

        return crmFegin.delLable(request);
    }

    @ApiOperation(value = "获取标签")
    @PostMapping("getTree")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<List<CompanyCustomerLableResponse>> getTree(CompanyCustomerLableRequest request) {
        ResultModel<List<CompanyCustomerLableResponse>> list = crmFegin.getTree(request);
        return list;
    }

    @ApiOperation(value = "修改标签")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lableId", value = "标签id", paramType = "Long"),
            @ApiImplicitParam(name = "lableColor", value = "标签颜色", paramType = "Long"),
            @ApiImplicitParam(name = "lableName", value = "标签名", paramType = "Long"),
            @ApiImplicitParam(name = "parentId", value = "标签父级id", paramType = "Long"),
    })
    @PostMapping("updLable")
    @SecurityAuthCheck(company = true, card = true, isBoss = true)
    public ResultModel<Boolean> updLable(@RequestAttribute CompanyCustomerLableRequest request) {

        return crmFegin.updLable(request);
    }
}
